# $Id$
# Maintainer: Eric Bélanger <eric@archlinux.org>

pkgname=libmad
pkgver=0.15.1b
pkgrel=7
pkgdesc="A high-quality MPEG audio decoder"
arch=('i686' 'x86_64')
url="http://www.underbit.com/products/mad/"
license=('GPL')
depends=('glibc')
source=(http://downloads.sourceforge.net/sourceforge/mad/${pkgname}-${pkgver}.tar.gz{,.sign}
        libmad.patch amd64-64bit.diff frame_length.diff optimize.diff)
sha1sums=('cac19cd00e1a907f3150cc040ccc077783496d76'
          '24c44ac7c96dca472e7305a7e59f1efd921a3499'
          '5e7369c77de2329f6542ffc4f633eec5a5245091'
          '97eba307b3343d5ba8938d59ec8f2c4b7449ae17'
          'b9c61ecacc6a6d47425d66f33327e0634cd8a33c'
          '3d5b958244ef0395ccdcb00344f2cf301ca07e34')
validpgpkeys=('4229B6BBA00DE143B485B74D2CE2036B4BF38A33')

prepare() {
  cd ${pkgname}-${pkgver}
  patch -p1 -i "${srcdir}/libmad.patch"
  patch -p1 -i "${srcdir}/amd64-64bit.diff"
  patch -p1 -i "${srcdir}/frame_length.diff"
  patch -p1 -i "${srcdir}/optimize.diff"
}

build() {
  cd ${pkgname}-${pkgver}
  CFLAGS="$CFLAGS -ftree-vectorize -ftree-vectorizer-verbose=1"
  autoconf
  ./configure --prefix=/usr
  make
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install
}
